//
//  TextViewController.m
//  ALittleReminder
//
//  Created by George on 13/11/2011.
//

#import "TextViewController.h"

@implementation TextViewController{
    AlertManagedObject * myAlert;
}
@synthesize textView;



- (id)initWithAlert:(AlertManagedObject *)alert
{
    self = [self initWithNibName:@"TextViewController" bundle:nil];
    if (self) {
        myAlert = alert;
    }
    return self;
}

- (IBAction)onDone:(id)sender {
    myAlert.text = textView.text;
    [self dismissModalViewControllerAnimated:YES];
}

- (IBAction)onClear:(id)sender {
    textView.text = @"";
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [textView becomeFirstResponder];
    textView.text = myAlert.text;
}

- (void)viewDidUnload
{
    myAlert = nil;
    [self setTextView:nil];
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
